# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models
from DjangoUeditor.models import UEditorField
# Create your models here.
from datetime import datetime

class Article(models.Model):

    ARTICLE_TYPE=(
        (1,"笔记"),
        (2,"随笔"),
    )
    title=models.CharField(default='', max_length=300, verbose_name=u'标题')
    shuoming=models.TextField(verbose_name="说明",  default='')
    article_desc = UEditorField(verbose_name="内容", imagePath="article/images/",
                              filePath="article/files/", default='')
    article_type = models.IntegerField(verbose_name=u'文章类型', choices=ARTICLE_TYPE)
    add_time = models.DateField(default=datetime.now, verbose_name=u'添加时间')
    click_nums = models.IntegerField(verbose_name=u'点击数', default=0)


    def get_message_nums(self):
        #获取课程章节数
        return self.mseeage_set.all().count()